$(function(){
    var E = window.wangEditor;
    var editor = new E('#editor');
    // 配置菜单
    editor.customConfig.menus = [
    'foreColor',
    'image'
    ];
    var QPOSTURL = 'Api.php/Question/quesstionPost';
    // 图片
    editor.customConfig.uploadImgServer = '/upload';
    editor.create();
    var quesstionPost = $("#quesstionPost");
    $("#ask-question-form").submit(function(event) {
        event.preventDefault();
        var $this = $(this);
        var title = $this.find("input[name='name']").val();
        var time = $this.find("input[name='time']").val();
        var mobile = $this.find("input[name='budget']").val();
        var content = editor.txt.html();
        if (!title.trim() || !time.trim() || !mobile.trim()) {
            return alert("请把信息填完整!");
        }
        if (content.length < 20) {
            return alert("问题描述太短了吧！");
        }
        $.ajax({
            url: QPOSTURL,
            type: 'POST',
            data: {
                title: title,
                time: time,
                content: content,
                mobile: mobile
            },
            success: function(data) {
                if(data.code === 0) {
                    // 成功之后跳转页面
                }
            }
        })
    });
})